#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include <iostream>
#include <string>
#include <unistd.h>
using namespace std;
class Channel
{
public:
    Channel(int write_fd, pid_t who)
        : _write_fd(write_fd), _who(who)
    {
        _name = "Channel-" + to_string(_write_fd) + "-" + to_string(who);
    }

    string Name()
    {
        return _name;
    }

    void Send(int cmd)
    {
        ::write(_write_fd,&cmd,sizeof(cmd));
    }

    void Close()
    {
        ::close(_write_fd);
    }

    ~Channel()
    {
    }

    int who()
    {
        return _who;
    }
private:
    int _write_fd;
    string _name;
    pid_t _who;
};
#endif